home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / HIERSV.PAK / HIERSVR.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  5KB  |  185 lines

  1. // hiersvr.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14. #include "stdafx.h"
  15. #include "hiersvr.h"
  16.  
  17. #include "mainfrm.h"
  18. #include "ipframe.h"
  19. #include "svrdoc.h"
  20. #include "svrview.h"
  21.  
  22. #ifdef _DEBUG
  23. #undef THIS_FILE
  24. static char BASED_CODE THIS_FILE[] = __FILE__;
  25. #endif
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CServerApp
  29.  
  30. BEGIN_MESSAGE_MAP(CServerApp, CWinApp)
  31.     //{{AFX_MSG_MAP(CServerApp)
  32.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  33.     //}}AFX_MSG_MAP
  34.     // Standard file based document commands
  35.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  36.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  37. END_MESSAGE_MAP()
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CServerApp construction
  41. // Place all significant initialization in InitInstance
  42.  
  43. CServerApp::CServerApp()
  44. {
  45. }
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // The one and only CServerApp object
  49.  
  50. CServerApp NEAR theApp;
  51.  
  52. // this is the GUID for HIERSVR documents
  53. static const GUID BASED_CODE clsid =
  54.     { 0x00021841, 0, 0, { 0xC0, 0, 0, 0, 0, 0, 0, 0x46 } };
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CServerApp initialization
  58.  
  59. BOOL CServerApp::InitInstance()
  60. {
  61. #if defined(_DEBUG) && !defined(_AFX_NO_DEBUG_CRT)
  62.     #ifndef _MAC
  63.         // turn on extra memory tracking
  64.         afxMemDF |= checkAlwaysMemDF;
  65.     #endif
  66. #endif
  67.  
  68.     // OLE 2.0 initialization
  69.     if (!AfxOleInit())
  70.     {
  71.         AfxMessageBox(IDP_AFXOLEINIT_FAILED);
  72.         return FALSE;
  73.     }
  74.  
  75.     // Standard initialization
  76.     Enable3dControls();
  77.     LoadStdProfileSettings();
  78.  
  79.     // Register document templates
  80.     CDocTemplate* pDocTemplate;
  81.     pDocTemplate = new CMultiDocTemplate(IDR_HIERSVRTYPE,
  82.             RUNTIME_CLASS(CServerDoc),
  83.             RUNTIME_CLASS(CMDIChildWnd),    // standard MDI child frame
  84.             RUNTIME_CLASS(CServerView));
  85.     pDocTemplate->SetServerInfo(
  86.         IDR_HIERSVRTYPE_SRVR_EMB, IDR_HIERSVRTYPE_SRVR_IP,
  87.         RUNTIME_CLASS(CInPlaceFrame), RUNTIME_CLASS(CServerView));
  88.     AddDocTemplate(pDocTemplate);
  89.  
  90.     // create main MDI Frame window
  91.     CMainFrame* pMainFrame = new CMainFrame;
  92.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  93.         return FALSE;
  94.     m_pMainWnd = pMainFrame;
  95.  
  96.     // enable file manager drag/drop and DDE Execute open
  97.     m_pMainWnd->DragAcceptFiles();
  98.     EnableShellOpen();
  99.  
  100.     // connect the COleTemplate server to the document template
  101.     m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
  102.     COleTemplateServer::RegisterAll();
  103.         // Note: MDI applications register all class objects regardless of
  104.         //  the /Embedding on the command line.
  105.  
  106.     // Parse command line for standard shell commands, DDE, file open
  107.     CCommandLineInfo cmdInfo;
  108.     ParseCommandLine(cmdInfo);
  109.  
  110.     // try to launch as an OLE server
  111.     if (cmdInfo.m_bRunEmbedded)
  112.     {
  113.         // application was run with /Embedding flag.  Instead of showing
  114.         //  the window, the application waits to receive OLE requests.
  115.         return TRUE;
  116.     }
  117.     
  118.     m_server.UpdateRegistry();
  119.     RegisterShellFileTypes(TRUE);
  120.     COleObjectFactory::UpdateRegistryAll();
  121.  
  122.     // Dispatch commands specified on the command line
  123.     if (!ProcessShellCommand(cmdInfo))
  124.         return FALSE;
  125.  
  126.     pMainFrame->ShowWindow(m_nCmdShow);
  127.     pMainFrame->UpdateWindow();
  128.  
  129.     return TRUE;
  130. }
  131.  
  132. int CServerApp::ExitInstance()
  133. {
  134.     return CWinApp::ExitInstance();
  135. }
  136.  
  137. /////////////////////////////////////////////////////////////////////////////
  138. // CAboutDlg dialog used for App About
  139.  
  140. class CAboutDlg : public CDialog
  141. {
  142. public:
  143.     CAboutDlg() : CDialog(CAboutDlg::IDD)
  144.     {
  145.     //{{AFX_DATA_INIT(CAboutDlg)
  146.     //}}AFX_DATA_INIT
  147.     }
  148.  
  149. // Dialog Data
  150.     //{{AFX_DATA(CAboutDlg)
  151.     enum { IDD = IDD_ABOUTBOX };
  152.     //}}AFX_DATA
  153.  
  154. // Implementation
  155. protected:
  156.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  157.     //{{AFX_MSG(CAboutDlg)
  158.         // No message handlers
  159.     //}}AFX_MSG
  160.     DECLARE_MESSAGE_MAP()
  161. };
  162.  
  163. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  164. {
  165.     CDialog::DoDataExchange(pDX);
  166.     //{{AFX_DATA_MAP(CAboutDlg)
  167.     //}}AFX_DATA_MAP
  168. }
  169.  
  170. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  171.     //{{AFX_MSG_MAP(CAboutDlg)
  172.         // No message handlers
  173.     //}}AFX_MSG_MAP
  174. END_MESSAGE_MAP()
  175.  
  176. // App command to run the dialog
  177. void CServerApp::OnAppAbout()
  178. {
  179.     CAboutDlg aboutDlg;
  180.     aboutDlg.DoModal();
  181. }
  182.  
  183. /////////////////////////////////////////////////////////////////////////////
  184. // CServerApp commands
  185.